package com.ee.chat.admin.controller.operatemanage;

import com.ee.chat.admin.service.IComplaintService;
import com.ee.chat.common.bean.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author AppiJ
 * @Date 2020/4/7 16:55
 */
@RestController
@RequestMapping("complaint")
public class ComplaintController {
    private Logger log = LoggerFactory.getLogger(ComplaintController.class);

    @Resource
    IComplaintService complaintService;

    /**
     * 获取投诉列表
     * @Author AppiJ
     * @Date 2020/4/7 17:09
     * @param
     * @return
     */
    @RequestMapping("list")
    public Result list(HttpServletRequest request, Integer userId, Integer toUserId, String createTime,
                       Integer status, @RequestParam Integer page, @RequestParam Integer limit){
        try{
            return complaintService.list(request, userId, toUserId, createTime, status, page, limit);
        }catch (Exception e){
            log.error("【获取投诉列表错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 处理投诉
     * @Author AppiJ
     * @Date 2020/4/8 15:16
     * @param
     * @return
     */
    @RequestMapping("updateStatus")
    public Result updateStatus(HttpServletRequest request, @RequestParam("ids[]") List<Integer> ids){
        try{
            return complaintService.updateStatus(request, ids);
        }catch (Exception e){
            log.error("【处理投诉错误】", e);
        }
        return Result.returnFailure();
    }
}
